load("@gazelle//:def.bzl", "gazelle")
load("@rules_go//go:def.bzl", "TOOLS_NOGO", "nogo")

# gazelle:prefix github.com/loeffel-io/ls-lint/v2
# gazelle:exclude vendor
# gazelle:exclude .idea
gazelle(name = "gazelle")

gazelle(
    name = "gazelle_fix_diff",
    command = "fix",
    extra_args = ["--mode=diff"],
)

config_setting(
    name = "darwin_arm64",
    constraint_values = [
        "@platforms//os:osx",
        "@platforms//cpu:arm64",
    ],
)

config_setting(
    name = "linux_amd64",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
    ],
)

config_setting(
    name = "windows_amd64",
    constraint_values = [
        "@platforms//os:windows",
        "@platforms//cpu:x86_64",
    ],
)

# TODO: https://github.com/bazel-contrib/rules_go/issues/4370
# currently disabled
nogo(
    name = "nogo",
    config = ":nogo.json",
    visibility = ["//visibility:public"],
    deps = TOOLS_NOGO + [],
)

exports_files(
    srcs = [
        "LICENSE",
        "README.md",
    ],
    visibility = ["//visibility:public"],
)

alias(
    name = "gh",
    actual = select({
        ":darwin_arm64": "@com_github_cli_cli_darwin_arm64//:bin/gh",
        ":linux_amd64": "@com_github_cli_cli_linux_amd64//:bin/gh",
        ":windows_amd64": "@com_github_cli_cli_windows_amd64//:bin/gh.exe",
    }),
    visibility = ["//visibility:public"],
)

alias(
    name = "coreutils",
    actual = select({
        ":darwin_arm64": "@com_github_uutils_coreutils_darwin_arm64//:coreutils",
        ":linux_amd64": "@com_github_uutils_coreutils_linux_amd64//:coreutils",
        ":windows_amd64": "@com_github_uutils_coreutils_windows_amd64//:coreutils.exe",
    }),
    visibility = ["//visibility:public"],
)
